[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
STRING CONSTANT
A string constant is a sequence of ASCII characters enclosed in
quotes, for example, "Hello", "Good-bye", or "Telix". It is often
necessary for a string constant to include special characters that
can not easily be typed from the keyboard, or can not be easily dis-
played. This is done with something called the escape character,
which is the caret ('^') symbol. When the SALT compiler is reading a
string constant and comes to the '^' symbol, it replaces it with a
certain ASCII code based on the character following the ^. Transla-
tions are as follows:
^c 'c' is a letter. The Control representation of what-
ever letter 'c' is, is inserted into the text. There-
fore ^M represents Ctrl-M, ^j represents Ctrl-J, etc.
Whether the letter 'c' is upper or lower case is not
significant. Note that what is really happening here
is that 64 is being subtracted from the value of 'c',
so for example, the Escape character can be repre-
sented as ^[.
^^ An actual caret ('^') symbol is placed into the text.
^" An actual double quote symbol ('"') is placed into
the text. If a string must contain a double quote
symbol, this is how it has to be done. If the plain
'"' symbol were to be used, the compiler would think
that the string was terminated at that point. For ex-
ample, the string "He said, ^"Hello^"." is translated
to 'He said, "Hello".'.
^' An actual single quote symbol (''') is placed into
the text.
^nnn 'nnn' is up to 3 digits representing the ASCII value
of the character which should be placed into the
text. A maximum of three digits is read, or up to the
first non-digit character. For example, the compiler
would read in the string "S^65LT" and output the
string "SALT", since 65 is the ASCII value of 'A'.
Note that if nnn is less than 3 digits you may have
to pad it with one or two leading zeros if there are
digits immediately following it in the string, so
that the wrong value is not read in. For example the
string "^79 Park Avenue" would translate to "O Park
Avenue" since 79 is the ASCII value of 'O'. If you
actually wanted Ctrl-G (ASCII code 7) followed by "9
Park Avenue", you would use the string "^0079 Park
Avenue".
See Also:
string variable
case
integer constant
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson